package com.zjp.mall.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;

public class JsonUtil {

    private static ObjectMapper mapper = new ObjectMapper();

    public  static  <T> T strToObj(String str,Class<T> t) throws IOException {
        return  mapper.readValue(str, t);
    }


    public static String objToStr(Object object) throws JsonProcessingException {
        return mapper.writeValueAsString(object);
    }

}
